package com.rentalcar.wechat.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.rentalcar.common.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.rentalcar.wechat.mapper.UmsMemberMapper;
import com.rentalcar.wechat.domain.UmsMember;
import com.rentalcar.wechat.service.IUmsMemberService;
import org.springframework.util.StringUtils;

/**
 * 会员Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-06-20
 */
@Service
@Slf4j
public class UmsMemberServiceImpl implements IUmsMemberService 
{
    @Autowired
    private UmsMemberMapper umsMemberMapper;

    /**
     * 查询会员
     * 
     * @param id 会员主键
     * @return 会员
     */
    @Override
    public UmsMember selectUmsMemberById(Long id)
    {
        return umsMemberMapper.selectUmsMemberById(id);
    }

    /**
     * 查询会员列表
     * 
     * @param umsMember 会员
     * @return 会员
     */
    @Override
    public List<UmsMember> selectUmsMemberList(UmsMember umsMember)
    {
        return umsMemberMapper.selectUmsMemberList(umsMember);
    }

    /**
     * 新增会员
     * 
     * @param umsMember 会员
     * @return 结果
     */
    @Override
    public int insertUmsMember(UmsMember umsMember)
    {
        umsMember.setCreateTime(DateUtils.getNowDate());
        return umsMemberMapper.insertUmsMember(umsMember);
    }

    /**
     * 修改会员
     * 
     * @param umsMember 会员
     * @return 结果
     */
    @Override
    public int updateUmsMember(UmsMember umsMember)
    {
        umsMember.setUpdateTime(DateUtils.getNowDate());
        return umsMemberMapper.updateUmsMember(umsMember);
    }

    /**
     * 批量删除会员
     * 
     * @param ids 需要删除的会员主键
     * @return 结果
     */
    @Override
    public int deleteUmsMemberByIds(Long[] ids)
    {
        return umsMemberMapper.deleteUmsMemberByIds(ids);
    }

    /**
     * 删除会员信息
     * 
     * @param id 会员主键
     * @return 结果
     */
    @Override
    public int deleteUmsMemberById(Long id)
    {
        return umsMemberMapper.deleteUmsMemberById(id);
    }

    @Override
    public UmsMember queryCustomerByh5OpenId(String openid, long storeId) {
        return null;
    }

    @Override
    public UmsMember queryCustomerByappOpenId(String openid, long storeId) {
        return null;
    }

    @Override
    public UmsMember queryCustomerByappletOpenId(String openid, long storeId) {
        return null;
    }

    @Override
    public UmsMember queryCustomerByName(String mobile, long storeId) {
        return null;
    }

    @Override
    public UmsMember queryCustomerInfoById(Long uid) {
        return null;
    }

    @Override
    public int isMobileExist(String mobile, long storeId) {
        return 0;
    }

    @Override
    public int registerCustomer(long storeId, String mobile, String password, String code, String value, String recommendCode) {
        return 0;
    }

    @Override
    public UmsMember queryCustomerWithNoPasswordById(long customerId) {
        return null;
    }

    @Override
    public UmsMember queryCustomerByNameInWriteDataSource(String userName) {
         log.debug("queryCustomerByNameInWriteDataSource and userName:{}", userName);

        if (StringUtils.isEmpty(userName)) {
            log.error("queryCustomerByNameInWriteDataSource fail due to userName is empty ....");
            return null;
        }

        Map<String, Object> params = new HashMap<>();
        params.put("username", userName);
        return umsMemberMapper.queryCustomerByNameInWriteDataSource(params);
    }
}
